package com.shun.upms.action;


import com.shun.common.R;
import com.shun.common.log.LogType;
import com.shun.common.log.annotation.ShunLog;
import com.shun.common.page.ShunPage;
import com.shun.upms.service.ISysAdminPostService;
import com.shun.upms.vo.SysAdminPost;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统内岗位表 前端控制器
 * </p>
 *
 * @author clever
 * @since 2021-10-10
 */
@Slf4j
@RestController
@RequestMapping("/upms/post/v1")
public class SysAdminPostAction {

    @Autowired
    private ISysAdminPostService postService;

    /**
     * 获取岗位分页
     * @return
     */
    @PostMapping("/pagePost")
    public R pagePost(@RequestBody ShunPage page){
        log.debug("page:{}",page);
        return postService.pageAdminPost(page);
    }

    /**
     * 删除岗位
     * @return
     */
    @GetMapping("/delPost/{postId}")
    @ShunLog(title = "岗位",logType = LogType.DELETE)
    public R delPost(@PathVariable("postId") String postId){
        log.debug("postId:{}",postId);
        return postService.delAdminPost(postId);
    }

    /**
     * 编辑岗位
     * @return
     */
    @PostMapping("/editPost")
    @ShunLog(title = "岗位",logType = LogType.UPDATE)
    public R editPost(@RequestBody SysAdminPost post){
        log.debug("post:{}",post);
        return postService.editAdminPost(post);
    }

    /**
     * 新增岗位
     * @return
     */
    @PostMapping("/addPost")
    @ShunLog(title = "岗位",logType = LogType.INSERT)
    public R addPost(@RequestBody SysAdminPost post){
        log.debug("post:{}",post);
        return postService.addAdminPost(post);
    }
}

